﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Netcached.Tests
{
    [TestClass]
    public class TestIncrementDecrement : BaseTestClass
    {
        [TestMethod]
        public void TestIncrement()
        {
            string key = "TestIncrementDecrement.TestIncrement";
            ulong initialValue = 50;
            ulong valueToIncreaseBy = 34;

            Client.InitializeCounter(key, initialValue);
            ulong? result = Client.Increment(key, valueToIncreaseBy);
            
            Assert.AreEqual(initialValue + valueToIncreaseBy, result);
        }

        [TestMethod]
        public void TestDecrement()
        {
            string key = "TestIncrementDecrement.TestDecrement";
            ulong initialValue = 55;
            ulong valueToDecreaseBy = 34;

            var res = Client.InitializeCounter(key, initialValue);
            ulong? result = Client.Decrement(key, valueToDecreaseBy);

            Assert.AreEqual(initialValue - valueToDecreaseBy, result);
        }

        [TestMethod]
        public void TestIncrementNonExisting()
        {
            string key = "TestIncrementDecrement.TestIncrementNonExisting";

            ulong? result = Client.Increment(key, 123);
            Assert.AreEqual(null, result);
        }
    }
}
